﻿#define MyAppName "数据采集工具"
#define MyAppVersion "1.0.0"
#define MyAppExeName "数据采集工具.exe"

[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename={#MyAppName}_安装程序_v{#MyAppVersion}
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
PrivilegesRequired=admin

[Files]
Source: "..\dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\dist\spiders\*"; DestDir: "{app}\spiders"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\utils\*"; DestDir: "{app}\utils"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\cookies\*"; DestDir: "{app}\cookies"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\dist\config.json"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\dist\version.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\VC_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall; Attribs: hidden

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Tasks]
Name: desktopicon; Description: "创建桌面快捷方式"; GroupDescription: "附加任务:"; MinVersion: 0,0

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "启动 {#MyAppName}"; Flags: postinstall nowait skipifdoesntexist

[Code]
function IsVcRedistInstalled: Boolean;
begin
  Result := 
    RegKeyExists(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64') or
    RegKeyExists(HKLM, 'SOFTWARE\Microsoft\VisualStudio\15.0\VC\Runtimes\x64') or
    RegKeyExists(HKLM, 'SOFTWARE\Microsoft\VisualStudio\16.0\VC\Runtimes\x64') or
    RegKeyExists(HKLM, 'SOFTWARE\Microsoft\VisualStudio\17.0\VC\Runtimes\x64');
end;
